<?php
$isadmin=1;
error_reporting(0);
include_once '../comm/config.php';
include 'check.php';
include("upload.class.php");
$CONF['jpeg_enable']   = '1';
$CONF['gif_enable']   = '1';
$CONF['png_enable']   = '1';
function extend_2($file_name)   
{   
$extend = pathinfo($file_name);   
$extend = strtolower($extend["extension"]);   
return $extend;   
} 
  if($_POST['vp'])
  {
  	if(extend_2($_FILES['up_pic']['name'])=="gif"||extend_2($_FILES['up_pic']['name'])=="jpg"||extend_2($_FILES['up_pic']['name'])=="png"){
		$prefix='pic_'.time().mt_rand(1,99999);
		$f_upload = new upload_file($prefix,"php,exe,rar,txt",'../upload/',512,$_FILES['up_pic']['type']);         
		$f_upload->set_file_name_size($_FILES['up_pic']['name'],$_FILES['up_pic']['size']);
		$f_upload->set_upfile($_FILES['up_pic']['tmp_name']); 
		$file_name = $f_upload->do_save();
		
		echo("	".chr(60). "script language=javascript>");
		echo("	function addcontent(tmpstr)");
		echo("	{");
		echo("		parent.document.form1.picname.value = tmpstr;");
		echo("	}");
		echo("  addcontent(\"".$file_name."\");");
		echo("	".chr(60)."/script>");
	
		echo " <html><body style=\"margin:0px;\"><table width=\"500\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"FONT-SIZE: 12px;\">图片上传成功！ <a href=../upload/".$file_name." target=_blank>查看</a> <a href=uppic.php>重新上传</a></td></tr></table></body></html>";
	}else{
		echo " <html><body style=\"margin:0px;\"><table width=\"500\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"FONT-SIZE: 12px;\">图片格式不允许！ <a href=uppic.php>重新上传</a></td></tr></table></body></html>";
	}
  }
 ?>
